<?php

class Admin_Model_Adsfor extends Zend_Db_Table_Abstract
{
    protected $_name = 'adsfor';
    public function getAllData(){
    	$query = $this->select()
                        ->setIntegrityCheck(false)
                        ->from(array('a'=>$this->_name))
                        ->join(array('e'=>'estate'),'a.estate =e.estateId', array('e.estateName'))
                        ->where("status =1");
    	return $this->fetchAll($query);
    }
    public function getDataById ($id){
    	$query = $this->select()
                        ->setIntegrityCheck(false)
                        ->from(array('a'=>$this->_name))
                        ->join(array('e'=>'estate'),'a.estate =e.estateId', array('e.estateName'))
                        ->where("status =1")
                        ->where('id = ?',(int)$id);
        return $this->fetchRow($query);
    }
    public function addData($title,$shortTitle,$createDate,$endDate,$startDate,$content,$transaction,$estate,$area,
    $price,$unit,$total,$address,$city='',$district='',$ward='',$project='',$contact,$mobile,$phoneContact='',$email,$status,$other){
        $data=array('title'=>$title,'shortTitle'=>$shortTitle,'createDate'=>$createDate,'endDate'=>$endDate,
        'startDate'=>$startDate,'content'=>$content,'transaction'=>$transaction,'estate'=>$estate,
        'area'=>$area,'price'=>$price,'unit'=>$unit,'total'=>$total,'address'=>$address,'district'=>$district,
        'city'=>$city,'ward'=>$ward,'project'=>$project,'contact'=>$contact,'mobile'=>$mobile,
        'phoneContact'=>$phoneContact,'email'=>$email,'status'=>$status,'other'=>$other);
        $id=$this->insert($data, $this->_name);
        return $id;
    }
}

